import React from 'react';
import { observer } from 'mobx-react';
import { WeaInput } from 'ecCom';
import _ from 'lodash';

@observer
export default class InputNew extends React.Component<any, any>{

    onChange = (v) => {
        const { onChange, fieldid } = this.props;
        onChange(fieldid, _.trim(v));
    }

    onPressEnter = (e) => {
        const v = _.trim(e.target.value);
        const { onPressEnter, fieldid, isChild } = this.props;
        onPressEnter(fieldid, v, isChild);
    }

    onBlur = (v) => {
        const { onBlur, fieldid, isChild } = this.props;
        onBlur(fieldid, _.trim(v), isChild);
    }

    render() {
        return <WeaInput
            {...this.props}
            onChange={this.onChange}
            onPressEnter={this.onPressEnter}
            onBlur={this.onBlur}
        ></WeaInput>
    }
}